package com.hae.shop.micoshoppayservice.mapper;

import com.hae.shop.micoshoppayservice.mapper.model.PayTransactionDo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 交易记录数据库交互接口
 */
public interface PayTransactionMapper {

    @Insert("INSERT INTO payment_transaction(user_id, order_id, pay_trans_id, pay_amount, payment_status, created_time, " +
            "updated_time) VALUES(#{userId}, #{orderId}, #{payTransId}, #{payAmount}, 1, now(), now())")
    int insertPayTransactionRecord(PayTransactionDo payTransactionDo);

    @Select("SELECT t.pay_trans_id as payTransId, t.ORDER_ID as orderId, t.USER_ID as userId, t.PAY_AMOUNT as payAmount, t.CREATED_TIME as createdTime " +
            "FROM payment_transaction t WHERE t.pay_trans_id = #{payTransId}")
    PayTransactionDo getPayTransactionByPayTransId(@Param("payTransId") String payTransId);
}
